package cn.larry.web.controller.system;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import cn.larry.common.annotation.Log;
import cn.larry.common.core.controller.BaseController;
import cn.larry.common.core.domain.AjaxResult;
import cn.larry.common.enums.BusinessType;
import cn.larry.system.domain.SysWxappConfig;
import cn.larry.system.service.ISysWxappConfigService;
import cn.larry.common.utils.poi.ExcelUtil;
import cn.larry.common.core.page.TableDataInfo;

/**
 * 微信应用管理Controller
 *
 * @author cn-larry
 * @date 2023-11-29
 */
@RestController
@RequestMapping("/system/wxappConfig")
public class SysWxappConfigController extends BaseController
{
    @Autowired
    private ISysWxappConfigService sysWxappConfigService;

    /**
     * 查询微信应用管理列表
     */
    @PreAuthorize("@ss.hasPermi('system:wxappConfig:list')")
    @GetMapping("/list")
    public TableDataInfo list(SysWxappConfig sysWxappConfig)
    {
        startPage();
        List<SysWxappConfig> list = sysWxappConfigService.selectSysWxappConfigList(sysWxappConfig);
        return getDataTable(list);
    }

    /**
     * 导出微信应用管理列表
     */
    @PreAuthorize("@ss.hasPermi('system:wxappConfig:export')")
    @Log(title = "微信应用管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, SysWxappConfig sysWxappConfig)
    {
        List<SysWxappConfig> list = sysWxappConfigService.selectSysWxappConfigList(sysWxappConfig);
        ExcelUtil<SysWxappConfig> util = new ExcelUtil<SysWxappConfig>(SysWxappConfig.class);
        util.exportExcel(response, list, "微信应用管理数据");
    }

    /**
     * 获取微信应用管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:wxappConfig:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(sysWxappConfigService.selectSysWxappConfigById(id));
    }

    /**
     * 新增微信应用管理
     */
    @PreAuthorize("@ss.hasPermi('system:wxappConfig:add')")
    @Log(title = "微信应用管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SysWxappConfig sysWxappConfig)
    {
        return toAjax(sysWxappConfigService.insertSysWxappConfig(sysWxappConfig));
    }

    /**
     * 修改微信应用管理
     */
    @PreAuthorize("@ss.hasPermi('system:wxappConfig:edit')")
    @Log(title = "微信应用管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SysWxappConfig sysWxappConfig)
    {
        return toAjax(sysWxappConfigService.updateSysWxappConfig(sysWxappConfig));
    }

    /**
     * 删除微信应用管理
     */
    @PreAuthorize("@ss.hasPermi('system:wxappConfig:remove')")
    @Log(title = "微信应用管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(sysWxappConfigService.deleteSysWxappConfigByIds(ids));
    }
}
